#include"comm.h"

int main()
{
  key_t k = ftok(PATHNAME,PROJ_ID);
  printf("key :%d\n",k);

  int shmid = shmget(k,SIZE,IPC_CREAT|IPC_EXCL|0666);
  if(shmid<0){
    perror("shmget");
    return 1;
  }
  
  printf("shmid:%d\n",shmid);

  //rm shmid 
  //sleep(10);

  char *str = (char*)shmat(shmid,NULL,0);
  sleep(5);
  
  int i = 0;
  while(i++ < 64){
    printf("client # %s\n",str);
    sleep(1);
  }
  shmdt(str);
  //sleep(5);
  shmctl(shmid,IPC_RMID,NULL);
  //sleep(10);

  return 0;
}
